﻿Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports SIAVU.Persistencia

Namespace Dominio
    <Serializable()> _
    Public Class Ciudad

#Region "Atributos privados"

        Private _CiudadID As Integer
        Private _Descripcion As String
        Private _Pais As String
        Private _Reglas As IList(Of Regla)

#End Region

#Region "Propiedades"

        Public Overridable Property CiudadID() As Long
            Get
                Return _CiudadID
            End Get
            Set(ByVal value As Long)
                _CiudadID = value
            End Set
        End Property

        Public Overridable Property Descripcion() As String
            Get
                Return _Descripcion
            End Get
            Set(ByVal value As String)
                _Descripcion = value
            End Set
        End Property

        Public Overridable Property Pais() As String
            Get
                Return _Pais
            End Get
            Set(ByVal value As String)
                _Pais = value
            End Set
        End Property

        Public Overridable Property Reglas() As IList(Of Regla)
            Get
                Return _Reglas
            End Get
            Set(ByVal value As IList(Of Regla))
                _Reglas = value
            End Set
        End Property

#End Region

#Region "Metodos"

        Public Overridable Function getByID(ByVal CiudadID As Integer) As Ciudad
            Try
                Dim oCiudadAux As New Ciudad
                oCiudadAux.CiudadID = CiudadID

                Dim oCiudadPersistencia As New CiudadPersistencia
                oCiudadPersistencia.getById(oCiudadAux)

                If oCiudadAux IsNot Nothing Then
                    Me.CiudadID = oCiudadAux.CiudadID
                    Me.Descripcion = oCiudadAux.Descripcion
                    Me.Pais = oCiudadAux.Pais
                    Me.Reglas = oCiudadAux.Reglas
                End If

                Return Me

            Catch ex As Exception
                Throw
            End Try
        End Function

        Public Overridable Function guardar() As Boolean
            Dim oCiudadPersistencia As New CiudadPersistencia

            Try
                oCiudadPersistencia.guardar(Me)
                Return True

            Catch ex As Exception
                Return False
            End Try
        End Function

#End Region

    End Class
End Namespace

